import time
from selenium.webdriver.common.keys import Keys
from dbshop1.public.action import *
from dbshop1.public.business import *
from dbshop1.public.testData import *
from dbshop1.public.tools import*
testCase="DBshop013_商品分类添加"
#打开网页并实例化
llq=openBrowser(urlAdmin)
#登入后台页面
DBshopLoginAdmin(llq)
#进入商品分类管理页面
DBshopEnterMenu3(llq,"商品管理","管理分类","商品分类")
#进入添加分类页面添加分类
llq.find_element_by_partial_link_text("添加分类").click()
llq.find_element_by_id("class_name").send_keys("商品分类测试")
llq.find_element_by_id("class_sort").send_keys(Keys.BACK_SPACE*4)
llq.find_element_by_id("class_sort").send_keys("1")
llq.find_element_by_xpath('//button[@class="btn btn-small btn-primary"]').click()
#修改类排序为4
llq.find_element_by_xpath('//td[contains(.,"商品分类测试")]/following-sibling::td[4]/a[2]').click()#xpath轴定位
llq.find_element_by_id("class_sort").send_keys(Keys.BACK_SPACE)
llq.find_element_by_id("class_sort").send_keys("4")
llq.find_element_by_xpath('//button[@class="btn btn-small btn-primary"]').click()
#断言
try:
    llq.find_element_by_xpath('//td[contains(.,"商品分类测试")]')
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(llq)
llq.quit()